number = int(input())
dominoes = []
for i in range(number):
domino = list(map(int, input().split()))
dominoes.append(domino)
left = 0
right = 0
for i in range(len(dominoes)):
left += dominoes[i][0]
right += dominoes[i][1]
different = 0
for i in range(len(dominoes)):
if (dominoes[i][0] % 2 == 0 and dominoes[i][1] % 2 == 1) or (dominoes[i][0] % 2 == 1 and dominoes[i][1] % 2 == 0):
different += 1
if left % 2 == 0 and right % 2 == 0:
print(0)
elif left % 2 == 1 and right % 2 == 1 and number != 1 and different >= 2:
print(1)
else:
print(-1)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <any>
using namespace std;
#ifdef LOCAL
#define eprintf(...) \
{ \
fprintf(stderr, __VA_ARGS__); \
fflush(stderr); \
}
#else
#define eprintf(...) 42
#endif
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
int MOD = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B)
{
return (ull)rng() % B;
}
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define print(...) cout << ... << endl;
#define nl "\n"
#define REPL(x, n) for(int x = 0; x < n; ++x)
clock_t startTime;
double getCurrentTime() {
return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
void printiv(vector<ll> v) {
for (int ele : v) {
cout << ele << " ";
}
cout << endl;
}
int main() {
int n;
int a,b;
int lsum=0, rsum=0;
bool pivot = false;
cin >> n;
REPL(i ,n ) {
cin >> a >> b;
if ((a % 2 == 1 && b % 2 == 0) || (a % 2 == 0 && b % 2 == 1)) {
pivot = true;
}
lsum += a; rsum += b;
}
if (lsum % 2 == 0 && rsum % 2 == 0) {
cout << 0 << nl;
} else if((lsum + rsum) % 2 == 0) {
if(pivot) {
cout << 1 << nl;
} else {
cout << -1 << nl;
}
} else {
cout << -1;
}
return 0;
}
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |